
package com.infindo.frame.util;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

 
public class InputStreamProvider {
	
	 public static int getMagicNumber(InputStream in) 
	      throws IOException {
	          int t = in.read();
	          System.out.println("t1:"+t+" char:"+(char)t);
	          if (t < 0) throw new EOFException("Failed to read magic number");
	          int magic = (t & 0xff) << 8;
	          System.out.println("magic1:"+magic);
	          t = in.read();
	          System.out.println("t2:"+t+" char:"+(char)t);
	           if (t < 0) throw new EOFException("Failed to read magic number");
	          magic += t & 0xff;
	          System.out.println("magic2:"+magic);
	           return magic;
     }
	 
		public static void appendInt(byte[] buf, int offset, int value) {
			buf[offset] = (byte) (value & 0xFF);
			buf[offset + 1] = (byte) ((value >> 8) & 0xFF);
			buf[offset + 2] = (byte) ((value >> 16) & 0xFF);
			buf[offset + 3] = (byte) ((value >> 24) & 0xFF);
		}
 
		public static int readInt(byte bvalue) {
			return (bvalue & 0xFF);
		}

}
